package com.avcdata.national.utils;

import android.content.Context;

import java.math.RoundingMode;
import java.text.DecimalFormat;

/**
 * NewAOSApp
 * com.avcdata.national.utils
 * Created by lic on 2017/8/21.
 * CSDN http://blog.csdn.net/lucasey
 */

public class MyUtils {

    /***
     * 格式化保留一位小数
     * @param value
     * @return
     */
    public static String format2(double value) {
        DecimalFormat df = new DecimalFormat("######0.0");
        return df.format(value);
    }

    /***
     * 格式化保留整数
     * @param value
     * @return
     */
    public static String format0(double value) {
        return (int)(Math.abs(value))+"";
    }

    /**
     * 根据手机分辨率从dp转到px
     */
    public static int dip2px(Context context, float dpValue) {
        final float scale = context.getResources ().getDisplayMetrics ().density;
        return (int) (dpValue * scale + 0.5f);
    }


}
